//
//  DBmanager.m
//  MeiShiDa
//
//  Created by zby on 15/7/1.
//  Copyright (c) 2015年 zby. All rights reserved.
//

#import "DBmanager.h"

@implementation DBmanager

+(DBmanager*)shareDBmanager{
    static DBmanager* dbManager = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        dbManager = [[DBmanager alloc] init];
        
    });
    
    return dbManager;
}

-(FMDatabase*)openOrCreateDB{
    
    NSString* dataBasePath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:@"db.sqlite"];
    self.db = [FMDatabase databaseWithPath:dataBasePath];
    if (![self.db open]) {
        NSLog(@"----%@",self.db);
        NSLog(@"could not open db");
    }
    return self.db;
}

@end
